//	ID : pallab81
// 	PROG : 10583
// 	LANG : C++
// 	2011-07-14-23.18.38 Thursday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define fo(i,ed) for(int i = 0 ; i < ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

const int inf = 50100;
int root[ inf ];
int rank[ inf ];
int rem[ inf ];

inline void Set() {
    fo(i,inf) {
        root[i]=i;
        rank[i]=0;
    }
}
inline int Find(int X) {
    if( X != root[X] ) {
        root[X] = Find( root[ X ] );
    }
    return root[X];
}
inline void Union(int X, int Y) {
    int rootX = Find(X);
    int rootY = Find(Y);
    if( rootX==rootY ){
        return ;
    }
    else if( rank[rootX] > rank[rootY] ) {
        root[ rootY ] = rootX;
    } else {
        root[ rootX ] = rootY;
    }
    if( rank[ rootX ] == rank[ rootY ] ) {
        rank[ rootY ]+=1;
    }
}
inline void proc(int N,int cases) {
    int i;
    SET( rem, -1);
    int result=0;
    for(i=1; i<=N; ++i) {
        if( rem[ Find(i) ]==-1 ) {
            ++result;
            rem[ Find(i) ] = 0;
        }
    }
    printf("Case %d: %d\n",cases,result);
}
inline void read(int N, Int M) {
    Int i;
    int x,y;
    Set();
    for(i=0; i<M; ++i) {
        scanf("%d %d",&x,&y);
        Union(x,y);
    }
}

int main() {
    int N;
    Int M;
    int cases=0;
    while( scanf("%d %lld",&N,&M)==2, ++cases) {
        if( N==0 && M==0 )break;
        read(N,M);
        proc(N,cases);
    }

    return 0;
}


